package com.efast.dmom.aps.entity;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.List;

import com.efast.dmom.aps.bean.ShiftItem;
import com.efast.dmom.aps.entity.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

/**
 * @author Aaron Liu
 *
 * @date:2020年2月7日
 */
public class PlanOrderScheduleInfoEntity extends BaseEntity {

	private static final long serialVersionUID = 9163122709677956568L;

	public PlanOrderScheduleInfoEntity() {
		// TODO Auto-generated constructor stub
	}

	private long planOrderId = 0;

	private long prodLineKey = 0;

	private double scheduledCount = 0;

	private double capacity = 0;
	
	private long shopId = 0;
	
	private long plantId = 0;

	private double workingHours = 0;
	
	private boolean isFullCapacity = false;

	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDate scheduleDate = null;

	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime lastScheduledTime = null;

	private List<ShiftItem> shiftItems = null;

	public LocalDateTime getLastScheduledTime() {
		return lastScheduledTime;
	}

	public void setLastScheduledTime(LocalDateTime lastScheduledTime) {
		this.lastScheduledTime = lastScheduledTime;
	}

	public static Comparator<PlanOrderScheduleInfoEntity> getTimeASC() {
		return timeASC;
	}

	public static void setTimeASC(Comparator<PlanOrderScheduleInfoEntity> timeASC) {
		PlanOrderScheduleInfoEntity.timeASC = timeASC;
	}

	public void setWorkingHours(int workingHours) {
		this.workingHours = workingHours;
	}

	public List<ShiftItem> getShiftItems() {
		return shiftItems;
	}

	public void setShiftItems(List<ShiftItem> shiftItems) {
		this.shiftItems = shiftItems;
	}

	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}

	public long getProdLineKey() {
		return prodLineKey;
	}

	public void setProdLineKey(long prodLineKey) {
		this.prodLineKey = prodLineKey;
	}

	public void setScheduledCount(int scheduledCount) {
		this.scheduledCount = scheduledCount;
	}

	public LocalDate getScheduleDate() {
		return scheduleDate;
	}

	public void setScheduleDate(LocalDate scheduleDate) {
		this.scheduleDate = scheduleDate;
	}

	public long getPlanOrderId() {
		return planOrderId;
	}

	public void setPlanOrderId(long planOrderId) {
		this.planOrderId = planOrderId;
	}

	public double getScheduledCount() {
		return scheduledCount;
	}

	public void setScheduledCount(double scheduledCount) {
		this.scheduledCount = scheduledCount;
	}

	public double getCapacity() {
		return capacity;
	}

	public void setCapacity(double capacity) {
		this.capacity = capacity;
	}

	public double getWorkingHours() {
		return workingHours;
	}

	public void setWorkingHours(double workingHours) {
		this.workingHours = workingHours;
	}
	
	public long getShopId() {
		return shopId;
	}

	public void setShopId(long shopId) {
		this.shopId = shopId;
	}

	public long getPlantId() {
		return plantId;
	}

	public void setPlantId(long plantId) {
		this.plantId = plantId;
	}
	
	public boolean isFullCapacity() {
		return isFullCapacity;
	}

	public void setFullCapacity(boolean isFullCapacity) {
		this.isFullCapacity = isFullCapacity;
	}

	public static Comparator<PlanOrderScheduleInfoEntity> timeASC = new Comparator<PlanOrderScheduleInfoEntity>() {

		@Override
		public int compare(PlanOrderScheduleInfoEntity info1, PlanOrderScheduleInfoEntity info2) {

			if (info1 == null) {
				return -1;
			}
			if (info2 == null) {
				return 1;
			}

			if (info1.getScheduleDate() == null) {
				return -1;
			}

			if (info2.getScheduleDate() == null) {
				return 1;
			}

			if (info1.getScheduleDate().isBefore(info2.getScheduleDate()))
				return -1;
			else if (info1.getScheduleDate().isAfter(info2.getScheduleDate())) {
				return 1;
			}

			return 0;
		}
	};

}
